package com.cloud.form.common.utils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import com.aspose.words.Document;
import com.aspose.words.SaveFormat;

public class WordHelper {
	
	/**
	 * Word转换为PDF
	 * @param content
	 * @return
	 */
	public static byte[] word2Pdf(byte[] content) {
		ByteArrayInputStream bis = null;
		ByteArrayOutputStream bos = null;
		try {
			bis = new ByteArrayInputStream(content);
			bos = new ByteArrayOutputStream();
			Document document = new Document(bis);
			document.save(bos, SaveFormat.PDF);
			bos.flush();
			return bos.toByteArray();
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			try {
				if (null != bis) {
					bis.close();
				}
				if (null != bos) {
					bos.close();
				}
			} catch (Exception e2) {
			}
		}
	}
}
